﻿using Quartz;
using System.Threading.Tasks;

namespace DataProcess.Core.Quartz.Jobs
{
    /// <summary>
    /// DisallowConcurrentExecution 特性表示禁用并发执行,一次只执行一个job. 
    /// 但是如果任务的执行时间大于间隔时间了，那么会在上一个结束的时候就开启新的job.
    /// </summary>
    [DisallowConcurrentExecution]
    public class SendFaultMessage : IJob
    {
#if NET40
        public void Execute(IJobExecutionContext context)
        {
            //DbContext<SampleTemp> dbContext = new DbContext<SampleTemp>();
            //var result = dbContext.CurrentDb.GetList();

            //int sucessCount = 0;

            //if (result.Count > 0)
            //{
            //    foreach (var item in result)
            //    {
            //        HttpHelper http = new HttpHelper();
            //        if (http.SendData(item.TargetEndpoint, item.Data, item.TargetAuthor, item.HttpRequestType))
            //        {
            //            //发送成功
            //            sucessCount++;
            //        }
            //    }
            //    Logger.Info($"失败数据重新发送{result.Count}条，成功{sucessCount}条");
            //}
        }
#elif (NET48 || NETSTANDARD)
        public Task Execute(IJobExecutionContext context)
        {
            return Task.CompletedTask;
        }
#endif
    }
}
